package com.example.test_01.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.databinding.DataBindingUtil;

import com.example.test_01.R;
import com.example.test_01.databinding.ActivityHomeBinding;
import com.example.test_01.model.User;
import com.example.test_01.utils.ActivityCollector;

public class Home extends BaseActivity implements View.OnClickListener {

    private static final String TAG = "HOME";
    private User user;

    Button BtnUserManage;
    Button BtnFoodTypeManage;
    Button BtnFoodManage;
    Button BtnExit;
    Button BtnOrder;
    Button BtnOrderShow;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent intent = getIntent();
        String Username = intent.getStringExtra("username");

        user = new User();
        user.setUsername(Username);
        ActivityHomeBinding homeBinding = DataBindingUtil.setContentView(this,R.layout.activity_home);
        homeBinding.setUser(user);

        BtnUserManage = findViewById(R.id.btn_user_manage);
        BtnUserManage.setOnClickListener(this);

        BtnFoodTypeManage = findViewById(R.id.btn_food_type_manage);
        BtnFoodTypeManage.setOnClickListener(this);

        BtnFoodManage = findViewById(R.id.btn_food_manage);
        BtnFoodManage.setOnClickListener(this);

        BtnOrder = findViewById(R.id.btn_order);
        BtnOrder.setOnClickListener(this);

        BtnOrderShow = findViewById(R.id.btn_order_manage);
        BtnOrderShow.setOnClickListener(this);

        BtnExit = findViewById(R.id.btn_exit);
        BtnExit.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.btn_user_manage:
            {
                Intent intent = new Intent(this,UserList.class);
                startActivity(intent);
            }
            break;
            case R.id.btn_exit:
            {
                ActivityCollector.finishAll();
            }
            break;
            case R.id.btn_food_type_manage:
            {
                Intent intent = new Intent(this, FoodTypeList.class);
                startActivity(intent);
            }
            break;
            case R.id.btn_food_manage:
            {
                Intent intent = new Intent(this, FoodList.class);
                startActivity(intent);
            }
            break;
            case R.id.btn_order:
            {
                Intent intent = new Intent(this, OrderList.class);
                startActivity(intent);
            }
            break;
            case R.id.btn_order_manage:
            {
                Intent intent = new Intent(this, OrderShow.class);
                startActivity(intent);
            }
        }
    }
}